package com.etcsoft.examples.ui.model;

import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;

public class Model {
    private int amount = 0;

    private PropertyChangeSupport changeSupport = new PropertyChangeSupport(this);

    public void addPropertyChangeListener(String propertyName,
            PropertyChangeListener listener) {
        changeSupport.addPropertyChangeListener(propertyName, listener);
    }

    public void removePropertyChangeListener(String propertyName,
            PropertyChangeListener listener) {
        changeSupport.removePropertyChangeListener(propertyName, listener);
    }

    public void setAmount(int newAmount) {
        int oldAmount = amount;
        amount = newAmount;
        changeSupport.firePropertyChange("amount", oldAmount, newAmount);
    }

    public int getAmount() {
        return amount;
    }
}
